CUR_PATH = ${shell pwd}

COMDRVS_PATH      := $(CUR_PATH)/../comdrvs

TEST_SRC          := $(CUR_PATH)/main.c
TEST_LIB_PATH     := $(CUR_PATH)/
TEST_OUT          := test.out

COMLIBS_LIB_NAME  := comlibs
COMLIBS_LIB_PATH  := /home/sxl/comlibs/build
COMLIBS_INCLUDE_PATH := /home/sxl/comlibs/include
COMDRVS_INCLUDE_PATH := $(COMDRVS_PATH)/include/api

CMDSERVER_PATH     := $(CUR_PATH)/cmd_server
CMDSERVER_INC_PATH := $(CMDSERVER_PATH)
CMDSERVER_LIB_PATH := $(CMDSERVER_PATH)
CMDSERVER_LIB_NAME := cmd_server

TEST_CFLAGS := -I$(COMLIBS_INCLUDE_PATH) \
               -I$(COMDRVS_INCLUDE_PATH) -I$(CMDSERVER_INC_PATH) \
	       -l${CMDSERVER_LIB_NAME} -L${CMDSERVER_LIB_PATH} \
	       -l${COMLIBS_LIB_NAME} -L${COMLIBS_LIB_PATH}


export COMLIBS_LIB_NAME COMLIBS_LIB_PATH
export COMLIBS_INCLUDE_PATH COMDRVS_INCLUDE_PATH

DRVLIB_CC     := /installs/xilinx/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin/arm-xilinx-linux-gnueabi-gcc
DRVLIB_AR     := /installs/xilinx/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin/arm-xilinx-linux-gnueabi-ar

export DRVLIB_CC DRVLIB_AR




all:
	make -C ${CMDSERVER_PATH}

	$(DRVLIB_CC) $(TEST_SRC) ${TEST_CFLAGS} -lpthread -o $(TEST_OUT)

dump_cmd:
	$(DRVLIB_CC) dump_cmd.c ${TEST_CFLAGS} -lpthread -o dump_cmd.out


clean:
	make -C ${CMDSERVER_PATH} clean
	rm -f *.a *.o *.out
